import type { FormSchemaGetter } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { DictEnum } from '@vben/constants';
import { getPopupContainer } from '@vben/utils';

// import { z } from '#/adapter/form';
import { getDictOptions } from '#/utils/dict';
// import { renderDict } from '#/utils/render';

export const querySchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'name',
    label: '区划名称',
  },
  {
    component: 'Input',
    fieldName: 'code',
    label: '区划编号',
  },
];

export const columns: VxeGridProps['columns'] = [
  {
    field: 'name',
    title: '区划名称',
    treeNode: true,
  },
  {
    field: 'code',
    title: '区划编号',
  },
  {
    field: 'sort',
    title: '排序',
  },
  // {
  //   field: 'status',
  //   title: '状态',
  //   slots: {
  //     default: ({ row }) => {
  //       return renderDict(row.status, DictEnum.SYS_NORMAL_DISABLE);
  //     },
  //   },
  // },
  // {
  //   field: 'createTime',
  //   title: '创建时间',
  // },
  {
    field: 'action',
    fixed: 'right',
    slots: { default: 'action' },
    title: '操作',
    resizable: false,
    width: 'auto',
  },
];

export const drawerSchema: FormSchemaGetter = () => [
  {
    component: 'TreeSelect',
    componentProps: {
      getPopupContainer,
      treeNodeFilterProp: 'name',
      disabled: true,
    },
    dependencies: {
      show: (model) => model.parentCode !== '',
      triggerFields: ['parentCode'],
    },
    fieldName: 'parentCode',
    label: '父区划',
    rules: 'selectRequired',
  },
  {
    component: 'Input',
    componentProps: {
      disabled: true,
    },
    fieldName: 'parentCode',
    label: '父区划编号',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'name',
    label: '区划名称',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'code',
    label: '区划编号',
    rules: 'required',
  },
  {
    component: 'RadioGroup',
    componentProps: {
      buttonStyle: 'solid',
      options: getDictOptions(DictEnum.SYS_REGION_LEVEL, true),
      optionType: 'button',
    },
    // defaultValue: '0',
    fieldName: 'level',
    label: '区划等级',
    rules: 'required',
  },
  {
    component: 'InputNumber',
    defaultValue: 1,
    fieldName: 'sort',
    label: '显示排序',
    rules: 'required',
  },
  {
    component: 'Textarea',
    fieldName: 'remark',
    label: '备注',
  },
  // {
  //   component: 'Input',
  //   dependencies: {
  //     show: () => false,
  //     triggerFields: [''],
  //   },
  //   fieldName: 'provinceName',
  //   label: '省份名称',
  // },
  // {
  //   component: 'RadioGroup',
  //   componentProps: {
  //     buttonStyle: 'solid',
  //     options: getDictOptions(DictEnum.SYS_NORMAL_DISABLE),
  //     optionType: 'button',
  //   },
  //   defaultValue: '0',
  //   fieldName: 'status',
  //   label: '状态',
  // },
];
